package SwordFingerOffer;

import java.util.logging.Level;

public class Q28_IsSymmetricTree {
    //判断镜像二叉树
    public static boolean isSymmetric(TreeNode root) {
        return root == null || recur(root.left, root.right);
    }

    public static boolean recur(TreeNode L, TreeNode R) {
        if(L == null && R == null) return true;
        if(L == null || R == null || L.val != R.val) return false;
        return recur(L.left, R.right) && recur(L.right, R.left);
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(2);
//        root.left.left = new TreeNode(3);
        root.left.right = new TreeNode(3);
        root.right.left = new TreeNode(3);
//        root.right.right = new TreeNode(3);
        System.out.println(isSymmetric(root));
    }
}
